import axios from 'axios'
async function callOpenAI() {
  const prompt = 'Hello, how are you?'
  const engine = 'text-davinci-002'
  const maxTokens = 5
  const YOUR_API_KEY = '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'
  const response = await axios.post(
    'https://api.openai.com/v1/engines/' + engine + '/completions',
    {
      prompt: prompt,
      max_tokens: maxTokens,
    },
    {
      headers: {
        'Content-Type': 'application/json',
        Authorization: 'Bearer ' + YOUR_API_KEY,
      },
    }
  )

  console.log(response.data.choices[0].text)
}
callOpenAI();
